import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

const userKey = 'User-Info'

export function getUser () {
  let data = Cookies.get(userKey) 
  return data
}

export function setUser (data) {
  if (typeof data === 'object') {
    data = JSON.stringify(data)
  }
  return Cookies.set(userKey, data)
}

export function removeUser() {
  return Cookies.remove(userKey)
}
